from typing import Any

from aiogram import types
from aiogram_dialog import Dialog, DialogManager, Window
from aiogram_dialog.widgets.kbd import Button, Cancel, Start

from app.bot.dialog.dialog_states import PaymentSG, UserProfileSG
from app.bot.dialog.getters.users import user_info_getter
from app.bot.dialog.widgets import LocaleText
from app.bot.handlers.client.orders.orders_history import user_orders
from app.bot.handlers.client.payment.payments_history import user_payments

user_profile_window = Window(
    LocaleText("your-account"),
    LocaleText("your-balance", balance="{user_balance}$"),
    LocaleText("your-email", email="{user_email}"),
    LocaleText("your-orders-count", orders_count="{orders_count}"),
    LocaleText("registered_date", reg_date="{reg_date}"),
    Start(
        LocaleText("add-balance-btn"),
        id="payment",
        state=PaymentSG.select_amount,
    ),
    Button(LocaleText("orders-btn"), id="proxy", on_click=user_orders),
    Button(LocaleText("my-vpns"), id="vpn", on_click=user_orders),
    Button(LocaleText("my-vpns-routers"), id="vpn_router", on_click=user_orders),
    Button(LocaleText("payments-btn"), id="user_payments", on_click=user_payments),
    Cancel(LocaleText("back-btn")),
    state=UserProfileSG.show_profile,
    getter=user_info_getter,
)

user_profile_dialog = Dialog(
    user_profile_window,
)


async def user_profile(
    message: types.Message, widget: Any, dialog_manager: DialogManager
):

    user_id = message.from_user.id

    await dialog_manager.start(UserProfileSG.show_profile, {"user_id": user_id})
